package util;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.LinkedList;
import java.util.Scanner;

/**
 * A collection of File Input/Output utilities
 * @author pedro
 *
 */
public final class FileUtil 
{
	//TODO write javadoc
	public static String[] readFileLines(File filename)
	{
		String[] lines = null;
		LinkedList<String> arrList = new LinkedList<String>(); 
		Scanner sc = null;
		
		try
		{
			sc = new Scanner(filename);
		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
			return lines;
		}
		
		while (sc.hasNextLine())
		{
			arrList.add(sc.nextLine());
		}
		
		lines = new String[arrList.size()];
		
		return arrList.toArray(lines);
	}
}
